import React, { useEffect, useRef } from 'react'

interface ReturnType {
  mountedRef: React.MutableRefObject<boolean>
}
type Fun = () => ReturnType

export const useMount: Fun = () => {
  const mountedRef = useRef(true)
  useEffect(() => () => {
    mountedRef.current = false
  }, [])
  return {
    mountedRef,
  }
}
